/*
 * @Description: 折线图
 * @Date: 2022-12-06 22:23:49
 * @Author: lizhiqiang
 */
import * as echarts from "echarts";
import { EChartOption, ECharts } from "echarts";
import { useEffect, useRef, useState } from "react";
interface Props {
    options: EChartOption
}
const LineChart = ( props: Props ) => {
    const { options } = props;
    const chartWrapper = useRef<HTMLDivElement>( null );
    const [ chart, setChart ] = useState<ECharts>();
    useEffect( () => {
        if ( chartWrapper.current ) {
            setChart( echarts.init( chartWrapper.current ) )
        }
    }, [] );
    useEffect( () => {
        chart?.setOption( options );
    }, [ options, chart ] )
    return (
        <div ref={ chartWrapper } style={ { height: '300px' } }></div>
    )
}
export default LineChart;